import React from 'react';
import { Button, Space } from 'antd';
import PropTypes from 'prop-types';
const onClick = (item) => {
  console.log('item', item);
  if (item?.type === 'search') {
    //todo
  }
  if (item?.type === 'reset') {
    //todo
  }
};

const mBtnList = ({ list }) => (
  <Space>
    {list?.map((item, i) => {
      return (
        <Button
          type={item.colorType || 'default'}
          key={i}
          size={item.size}
          icon={item.icon}
          onClick={(e) => onClick(item)}
        >
          {item.text}
        </Button>
      );
    })}
  </Space>
);
mBtnList.propTypes = {
  list: PropTypes.array,
};
/* 传值的默认值设置 */
mBtnList.defaultProps = {
  list: [
    {
      text: '搜索',
      type: 'search',
      colorType: 'primary',
      size: 'middle',
    },
    {
      text: '重置',
      type: 'reset',
      size: 'middle',
    },
  ],
};
export default mBtnList;
